<?php
/**
 * @var \Mslynn\Customer\Block\Dob $block
 */
$month=$block->getMonth();
$day=$block->getDay();
$year=$block->getYear();
$defaultDay=intval($block->getDefaultDay());

$defaultMonth=$block->getDefaultMonth();

$defaultYear=$block->getDefaultYear();

if ($defaultYear&&$defaultMonth&&$defaultYear){
    $time=$defaultMonth.'/'.$defaultDay.'/'.$defaultYear ;
}else{
    $time='';
}
?>
<div class="field gender">
    <label class="label"  style="position: relative" for="<?php echo $block->getLabel(); ?>"><span><?php echo $block->getLabel(); ?></span>

        <span class="register-window-birthday_quest" style="

    bottom: 5px;
    display: inline-block;
    width: 20px;
    height: 20px;
    top: 11px;
    left: 86px;
    background: #999;
    border-radius: 50%;
    color: #fff;
    text-align: center;
    line-height: 21px;
    cursor: pointer;
    padding-bottom: 0 !important;">?</span>
        <p class="register-window-birthday_answer" style="
        display: none;
    position: absolute;
    width: 242px;
    height: auto;
    left: 120px;
    top: 28px;
    padding: 10px;
    box-sizing: border-box;
    border: 1px solid #f2f2f2;
    box-shadow: 0 2px 3px 0 #ccc;
    background: #fff;
    color: #333;
    font-size: 12px;
    z-index: 2;">Providing your birthday helps make sure you get better experience for your age,it won't shows in public. <button type="button" class="register-window-birthday_answer_btn">close</button></p>
    </label>
    <div class="control" style="display: flex;justify-content: space-between">
        <select id="month" name="month" title="month" style="width: 30%">
            <?php foreach ($month as $k=>$v){?>
                <option value="<?php echo $v['value'] ;?>"   <?php if ($defaultMonth==$v['value'])  { ?> selected="selected" <?php }  ?> > <?php echo $v['option'];?> </option>
            <?php } ?>

        </select>
        <select id="day" name="day" title="day" style="width: 30%">
            <?php foreach ($day as $k=>$v){?>
                <option value="<?php echo $v['value'] ;?>"  <?php if ($defaultDay==$v['value'])  { ?> selected="selected" <?php }  ?> > <?php echo $v['option'];?> </option>
            <?php } ?>

        </select>
        <select id="year" name="year" title="year" style="width: 30%">
            <?php foreach ($year as $k=>$v){?>
                <option value="<?php echo $v['value'] ;?>" <?php if ($defaultYear==$v['value'])  { ?> selected="selected" <?php }  ?>  > <?php echo $v['option'];?> </option>
            <?php } ?>
        </select>
        <input name="dob" id="dob" type="hidden"    value="<?php echo $time;  ?>" >
    </div>
</div>
<script>
    require(['jquery'],function ($){
            $("#month").change(function(){
                let dob=$("#month").val()+'/'+$("#day").val()+'/'+$("#year").val()
                console.log(dob)
                $("#dob").val(dob)
            })
            $("#day").change(function(){
                let dob=$("#month").val()+'/'+$("#day").val()+'/'+$("#year").val()
                console.log(dob)
                $("#dob").val(dob)
            })
            $("#year").change(function(){
                let dob=$("#month").val()+'/'+$("#day").val()+'/'+$("#year").val()
                console.log(dob)
                $("#dob").val(dob)
            })
        $(".register-window-birthday_quest").click(function (){
            $(".register-window-birthday_answer").show()
        })
        $(".register-window-birthday_answer_btn").click(function (){
            $(".register-window-birthday_answer").hide()
        })
    })
</script>